package com.chao.stucture.tree;

/**
 * @author : Rookie
 * @description :
 * @date : 2022/12/25
 */
public class BinaryTraversal {

    public static void main(String[] args) {
        int[] input = {1, 2, 3, -1, 5, -1, 4};
        TreeNode root = BinaryTreeUtil.buildTree(input);
        BinaryTreeUtil.Traversal rt = new BinaryTreeUtil.RecursiveTraversal();
        BinaryTreeUtil.Traversal it = new BinaryTreeUtil.IterativeTraversal();
        System.out.println("======层序遍历======");
        BinaryTreeUtil.Traversal.sequenceTraversal(root);
        System.out.println("\n======前序遍历-递归实现======");
        rt.preorderTraversal(root);
        System.out.println("\n======中序遍历-递归实现======");
        rt.inorderTraversal(root);
        System.out.println("\n======后序遍历-递归实现======");
        rt.postorderTraversal(root);
        System.out.println("\n======前序遍历-迭代实现======");
        it.preorderTraversal(root);
        System.out.println("\n======中序遍历-迭代实现======");
        it.inorderTraversal(root);
    }
}
